package com.itheima.jingjie.hashset;

import java.util.HashSet;
import java.util.Iterator;

public class HashSetDemo1 {
    public static void main(String[] args) {
        HashSet<String> hash = new HashSet<>();
        hash.add("hello");
        hash.add("world");
        hash.add("java");
        hash.add("java");
        hash.add("java");
        hash.add("java");
        hash.add("java");
        for (String s : hash) {
            System.out.println(s);
        }
        System.out.println(".........................");
        Iterator<String> iterator = hash.iterator();
        while (iterator.hasNext()) {
            String next = iterator.next();
            System.out.println(next);
        }
        System.out.println(".........................");
        hash.forEach((String s) -> {
            System.out.println(s);
        });
    }
}
